<?php
/**
 * Created by PhpStorm.
 * User: junyv
 * Date: 2017/4/17
 * Time: 15:06
 */

namespace app\home\controller\user;


class Store extends Common
{
    private $mod;
    public function _initialize()
    {
        parent::_initialize();
        $this->mod = model('store');
        $this->_name = 'Store';
    }
    public function index(){
        $info = $this->mod->where(['user_id'=>$this->userInfo['id']])->find();
        $tpl  = $info ? 'user/store/edit' : 'user/store/index';
        $this->assign('info',$info);
        return $this->fetch($tpl);
    }
    public function addDo(){
        \app\common\model\Store::event('before_insert',function($obj){
            $obj->user_id = $this->userInfo['id'];
        });
        parent::addDo();
    }
}